package com.base.library.view.systemPhotoAlbum;

import android.os.Bundle;

import com.base.library.R;
import com.base.library.activity.BaseActivity;
import com.base.library.view.galleryViewPager.BasePagerAdapter;
import com.base.library.view.galleryViewPager.GalleryViewPager;
import com.base.library.view.galleryViewPager.UrlPagerAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * 作者：王东一 on 2016/5/31 11:00
 **/
public class PhotoInfoActivity extends BaseActivity {
    private GalleryViewPager mViewPager;
    private ArrayList<PhotoInfoFragment> fragments = new ArrayList<>();
    private PhotoInfoFragment mPhotoInfoFragment;
    private gallery_adapter gallery_adapter;
    private UrlPagerAdapter pagerAdapter;
    private List<String> items = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.phone_info_activity);
        init();
    }

    private void init() {
        setTitleName("图片详情");
        items = getIntent().getStringArrayListExtra("path");
        int position = getIntent().getIntExtra("position", 0);
        mViewPager = (GalleryViewPager) findViewById(R.id.gallery);
        pagerAdapter = new UrlPagerAdapter(this, items);
        pagerAdapter.setOnItemChangeListener(new BasePagerAdapter.OnItemChangeListener() {
            @Override
            public void onItemChange(int currentPosition) {
//                pagerAdapter.clean();
            }
        });
        mViewPager.setAdapter(pagerAdapter);
        mViewPager.setOffscreenPageLimit(0);
        if (position < items.size())
            mViewPager.setCurrentItem(position);
    }

    @Override
    protected void onDestroy() {
        pagerAdapter.clean();
        super.onDestroy();
    }
}
